<!DOCTYPE html>
<html lang="ch" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>登录</title>
    <link rel="stylesheet" th:href="@{/login/css/normalize.css}">
    <link rel="stylesheet" th:href="@{/login/css/login.css}">
    <link rel="stylesheet" th:href="@{/login/css/sign-up-login.css}">
    <link rel="stylesheet" type="text/css" href="http://cdn.bootcss.com/font-awesome/4.6.0/css/font-awesome.min.css">
    <link rel="stylesheet" th:href="@{/login/css/inputEffect.css}" />
    <link rel="stylesheet" th:href="@{/login/css/tooltips.css}" />
    <link rel="stylesheet" th:href="@{/login/css/spop.min.css}" />

    <script th:src="@{/login/js/jquery.min.js}"></script>
    <script th:src="@{/login/js/snow.js}"></script>
    <script th:src="@{/login/js/jquery.pure.tooltips.js}"></script>
    <script th:src="@{/login/js/spop.min.js}"></script>
    <script th:src="@{/js/jquery.base64.js}" type="text/javascript"></script>
    <script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
    <script>
        (function() {
            // trim polyfill : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim
            if (!String.prototype.trim) {
                (function() {
                    // Make sure we trim BOM and NBSP
                    var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
                    String.prototype.trim = function() {
                        return this.replace(rtrim, '');
                    };
                })();
            }

            [].slice.call( document.querySelectorAll( 'input.input__field' ) ).forEach( function( inputEl ) {
                // in case the input is already filled..
                if( inputEl.value.trim() !== '' ) {
                    classie.add( inputEl.parentNode, 'input--filled' );
                }

                // events:
                inputEl.addEventListener( 'focus', onInputFocus );
                inputEl.addEventListener( 'blur', onInputBlur );
            } );

            function onInputFocus( ev ) {
                classie.add( ev.target.parentNode, 'input--filled' );
            }

            function onInputBlur( ev ) {
                if( ev.target.value.trim() === '' ) {
                    classie.remove( ev.target.parentNode, 'input--filled' );
                }
            }
        })();

        $(function() {
            $("#ip").val(returnCitySN["cip"]);
            $("#ipHome").val(returnCitySN["cname"]);

            $('#login #login-password').focus(function() {
                $('.login-owl').addClass('password');
            }).blur(function() {
                $('.login-owl').removeClass('password');
            });
            $('#login #register-password').focus(function() {
                $('.register-owl').addClass('password');
            }).blur(function() {
                $('.register-owl').removeClass('password');
            });
            $('#login #register-repassword').focus(function() {
                $('.register-owl').addClass('password');
            }).blur(function() {
                $('.register-owl').removeClass('password');
            });
            $('#login #forget-password').focus(function() {
                $('.forget-owl').addClass('password');
            }).blur(function() {
                $('.forget-owl').removeClass('password');
            });
        });

        function goto_register(){
            $("#register-username").val("");
            $("#register-account").val("");
            $("#register-password").val("");
            $("#register-repassword").val("");
            $("#register-email").val("");
            $("#register-code").val("");
            $("#tab-2").prop("checked",true);
        }

        function goto_login(){
            $("#login-username").val("");
            $("#login-password").val("");
            $("#tab-1").prop("checked",true);
        }

        function goto_forget(){
            $("#forget-username").val("");
            $("#forget-password").val("");
            $("#forget-email").val("");
            $("#forget-code").val("");
            $("#tab-3").prop("checked",true);
        }

        function login(){//登录
            var username = $("#login-username").val(),
                password = $("#login-password").val(),
                validatecode = null,
                flag = false;
            //判断用户名密码是否为空
            if(username == ""){
                $.pt({
                    target: $("#login-username"),
                    position: 'r',
                    align: 't',
                    width: 'auto',
                    height: 'auto',
                    content:"用户名不能为空"
                });
                flag = true;
            }
            if(password == ""){
                $.pt({
                    target: $("#login-password"),
                    position: 'r',
                    align: 't',
                    width: 'auto',
                    height: 'auto',
                    content:"密码不能为空"
                });
                flag = true;
            }
            //用户名只能是15位以下的字母或数字
            var regExp = new RegExp("^[a-zA-Z0-9_]{1,15}$");
            if(!regExp.test(username)){
                $.pt({
                    target: $("#login-username"),
                    position: 'r',
                    align: 't',
                    width: 'auto',
                    height: 'auto',
                    content:"用户名必须为15位以下的字母或数字"
                });
                flag = true;
            }

            if(flag){
                return false;
            }else{//登录
                //调用后台登录验证的方法
                $.ajax({
                    type:'post',
                    url:'/loginCenter/login',
                    data:{"username":username,"password":$.base64.encode(password),"ip":$("#ip").val(),"ipHome":$("#ipHome").val()},
                    dataType: "text",
                    async: false,
                    success:function (data) {
                        console.log(data);
                        if (data == 1){
                            window.location.href = '/user/index';
                        }else if(data == 2){
                            $.pt({
                                target: $("#login-username"),
                                position: 'r',
                                align: 't',
                                width: 'auto',
                                height: 'auto',
                                content:"用户名不存在"
                            });
                        }else if(data == 3) {
                            $.pt({
                                target: $("#login-password"),
                                position: 'r',
                                align: 't',
                                width: 'auto',
                                height: 'auto',
                                content:"密码有误"
                            });
                        }
                    },
                    error:function () {
                        alert("登录异常");
                    }
                });
                return false;
            }
        }

        //注册
        function register(){
            var username = $("#register-username").val(),
                password = $("#register-password").val(),
                repassword = $("#register-repassword").val(),
                code = $("#register-code").val(),
                account = $("#register-account").val(),
                email = $("#register-email").val(),
                flag = false,
                validatecode = null;
            //判断用户名密码是否为空
            if(username == ""){
                $.pt({
                    target: $("#register-username"),
                    position: 'r',
                    align: 't',
                    width: 'auto',
                    height: 'auto',
                    content:"用户名不能为空"
                });
                flag = true;
            }
            if(account == ""){
                $.pt({
                    target: $("#register-username"),
                    position: 'r',
                    align: 't',
                    width: 'auto',
                    height: 'auto',
                    content:"用户名不能为空"
                });
                flag = true;
            }
            if(password == ""){
                $.pt({
                    target: $("#register-password"),
                    position: 'r',
                    align: 't',
                    width: 'auto',
                    height: 'auto',
                    content:"密码不能为空"
                });
                flag = true;
            }else{
                if(password != repassword){
                    $.pt({
                        target: $("#register-repassword"),
                        position: 'r',
                        align: 't',
                        width: 'auto',
                        height: 'auto',
                        content:"两次输入的密码不一致"
                    });
                    flag = true;
                }
            }
            //用户名只能是15位以下的字母或数字
            var regExp1 = new RegExp("^[a-zA-Z0-9_]{1,15}$");
            if(!regExp1.test(username)){
                $.pt({
                    target: $("#register-username"),
                    position: 'r',
                    align: 't',
                    width: 'auto',
                    height: 'auto',
                    content:"用户名必须为15位以下的字母或数字"
                });
                flag = true;
            }
            //account15为字母数字下划线
            var regExp3 = new RegExp("^[\u4E00-\u9FA5A-Za-z0-9_]+$");
            if(!regExp3.test(account)){
                $.pt({
                    target: $("#register-account"),
                    position: 'r',
                    align: 't',
                    width: 'auto',
                    height: 'auto',
                    content:"笔名必须为15为以下中文、字母、数字和_组成"
                });
                flag = true;
            }
            //检查用户名和笔名是否已经存在
            //调后台代码检查用户名是否已经被注册

            $.ajax({
                type:'post',
                url:'/loginCenter/check',
                data:{"username":username,"account":account,"code":code,"email":email},
                dataType: "text",
                async: false,
                success:function (data) {
                    console.log(data);
                    if (data==1){
                        return false;
                    }else if(data==0){
                        $.pt({
                            target: $("#register-username"),
                            position: 'r',
                            align: 't',
                            width: 'auto',
                            height: 'auto',
                            content:"用户名已存在"
                        });
                        flag = true;
                    }else if(data==-1){
                        $.pt({
                            target: $("#register-account"),
                            position: 'r',
                            align: 't',
                            width: 'auto',
                            height: 'auto',
                            content:"此笔名已被使用"
                        });
                        flag = true;
                    }else if(data==-2){
                        $.pt({
                            target: $("#register-code"),
                            position: 'r',
                            align: 't',
                            width: 'auto',
                            height: 'auto',
                            content:"验证码不能为空"
                        });
                        flag = true;
                    }else if(data==-3){
                        $.pt({
                            target: $("#register-code"),
                            position: 'r',
                            align: 't',
                            width: 'auto',
                            height: 'auto',
                            content:"验证码以过期"
                        });
                        flag = true;
                    }else if(data==-4){
                        $.pt({
                            target: $("#register-code"),
                            position: 'r',
                            align: 't',
                            width: 'auto',
                            height: 'auto',
                            content:"验证码有误"
                        });
                        flag = true;
                    }
                },
                error:function () {
                    alert("注册异常");
                }
            });

            if(flag){
                return false;
            }else{//注册
                $.ajax({
                    type:'post',
                    url:'/loginCenter/register',
                    data:{"username":username,"password":$.base64.encode(password),"account":account,"email":email,"ip":$("#ip").val(),"ipHome":$("#ipHome").val()},
                    dataType: "text",
                    async: false,
                    success:function (data) {
                        console.log(data);
                        if (data==200){
                            return false;
                        }else if(data==134){
                            $.pt({
                                target: $("#register-username"),
                                position: 'r',
                                align: 't',
                                width: 'auto',
                                height: 'auto',
                                content:"用户名已存在"
                            });
                            flag = true;
                        }else if(data==135){
                            $.pt({
                                target: $("#register-account"),
                                position: 'r',
                                align: 't',
                                width: 'auto',
                                height: 'auto',
                                content:"此笔名已被使用"
                            });
                            flag = true;
                        }else if(data==502){
                            spop({
                                template: '<h4 class="spop-title">系统异常</h4>请在3秒后从新操作',
                                position: 'top-center',
                                style: 'success',
                                autoclose: 3000,
                                onOpen : function(){
                                    var second = 2;
                                    var showPop = setInterval(function(){
                                        if(second == 0){
                                            clearInterval(showPop);
                                        }
                                        $('.spop-body').html('<h4 class="spop-title">系统异常</h4>请在'+second+'秒后从新操作');
                                        second--;
                                    },1000);
                                },
                                onClose : function(){
                                    /*goto_login();*/
                                }
                            });
                        }
                    },
                    error:function () {
                        alert("注册异常");
                    }
                });
                spop({
                    template: '<h4 class="spop-title">注册成功</h4>即将于3秒后返回登录',
                    position: 'top-center',
                    style: 'success',
                    autoclose: 3000,
                    onOpen : function(){
                        var second = 2;
                        var showPop = setInterval(function(){
                            if(second == 0){
                                clearInterval(showPop);
                            }
                            $('.spop-body').html('<h4 class="spop-title">注册成功</h4>即将于'+second+'秒后返回登录');
                            second--;
                        },1000);
                    },
                    onClose : function(){
                        goto_login();
                    }
                });
                return false;
            }
        }

        //重置密码
        function forget(){
            var username = $("#forget-username").val(),
                password = $("#forget-password").val(),
                email = $("#forget-email").val(),
                code = $("#forget-code").val(),
                flag = false,
                validatecode = null;
            //判断用户名密码是否为空
            if(username == ""){
                $.pt({
                    target: $("#forget-username"),
                    position: 'r',
                    align: 't',
                    width: 'auto',
                    height: 'auto',
                    content:"用户名不能为空"
                });
                flag = true;
            }
            if(password == ""){
                $.pt({
                    target: $("#forget-password"),
                    position: 'r',
                    align: 't',
                    width: 'auto',
                    height: 'auto',
                    content:"密码不能为空"
                });
                flag = true;
            }
            //用户名只能是15位以下的字母或数字
            var regExp = new RegExp("^[a-zA-Z0-9_]{1,15}$");
            if(!regExp.test(username)){
                $.pt({
                    target: $("#forget-username"),
                    position: 'r',
                    align: 't',
                    width: 'auto',
                    height: 'auto',
                    content:"用户名必须为15位以下的字母或数字"
                });
                flag = true;
            }
            $.ajax({
                type:'post',
                url:'/loginCenter/forgetCheck',
                data:{"username":username,"code":code,"email":email},
                dataType: "text",
                async: false,
                success:function (data) {
                    if (data==1){
                        return false
                    }else if(data==-1){
                        $.pt({
                            target: $("#forget-username"),
                            position: 'r',
                            align: 't',
                            width: 'auto',
                            height: 'auto',
                            content:"用户不存在"
                        });
                        flag = true;
                    }else if(data==-2){
                        $.pt({
                            target: $("#forget-code"),
                            position: 'r',
                            align: 't',
                            width: 'auto',
                            height: 'auto',
                            content:"验证码不能为空"
                        });
                        flag = true;
                    }else if(data==-3){
                        $.pt({
                            target: $("#forget-code"),
                            position: 'r',
                            align: 't',
                            width: 'auto',
                            height: 'auto',
                            content:"验证码以过期"
                        });
                        flag = true;
                    }else if(data==-4){
                        $.pt({
                            target: $("#forget-code"),
                            position: 'r',
                            align: 't',
                            width: 'auto',
                            height: 'auto',
                            content:"验证码有误"
                        });
                        flag = true;
                    }
                },
                error:function () {
                    alert("重置密码异常");
                }
            });

            if(flag){
                return false;
            }else{//重置密码
                $.ajax({
                    type:'post',
                    url:'/loginCenter/forget',
                    data:{"username":username,"password":$.base64.encode(password)},
                    dataType: "text",
                    async: false,
                    success:function (data) {
                        console.log(data);
                        if (data==1){
                            return false
                        }
                    },
                    error:function () {
                        alert("重置密码异常");
                    }
                });
                spop({
                    template: '<h4 class="spop-title">重置密码成功</h4>即将于3秒后返回登录',
                    position: 'top-center',
                    style: 'success',
                    autoclose: 3000,
                    onOpen : function(){
                        var second = 2;
                        var showPop = setInterval(function(){
                            if(second == 0){
                                clearInterval(showPop);
                            }
                            $('.spop-body').html('<h4 class="spop-title">重置密码成功</h4>即将于'+second+'秒后返回登录');
                            second--;
                        },1000);
                    },
                    onClose : function(){
                        goto_login();
                    }
                });
                return false;
            }
        }







    </script>
    <style type="text/css">
        html{width: 100%; height: 100%;}

        body{

            background-repeat: no-repeat;

            background-position: center center #2D0F0F;

            background-color: #00BDDC;

            background-image: url(/login/images/snow.jpg);

            background-size: 100% 100%;

        }

        .snow-container { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 100001; }

    </style>
</head>
<body>
<input id="ip" name="ip" type="hidden">
<input id="ipHome" name="ipHome" type="hidden">
<!-- 雪花背景 -->
<div class="snow-container"></div>
<!-- 登录控件 -->
<div id="login">
    <input id="tab-1" type="radio" name="tab" class="sign-in hidden" checked />
    <input id="tab-2" type="radio" name="tab" class="sign-up hidden" />
    <input id="tab-3" type="radio" name="tab" class="sign-out hidden" />
    <div class="wrapper">
        <!-- 登录页面 -->
        <div class="login sign-in-htm">
            <form class="container offset1 loginform">
                <!-- 猫头鹰控件 -->
                <div id="owl-login" class="login-owl">
                    <div class="hand"></div>
                    <div class="hand hand-r"></div>
                    <div class="arms">
                        <div class="arm"></div>
                        <div class="arm arm-r"></div>
                    </div>
                </div>
                <div class="pad input-container">
                    <section class="content">
							<span class="input input--hideo">
								<input class="input__field input__field--hideo" type="text" id="login-username"
                                       autocomplete="off" placeholder="请输入用户名" tabindex="1" maxlength="15" />
								<label class="input__label input__label--hideo" for="login-username">
									<i class="fa fa-fw fa-user icon icon--hideo"></i>
									<span class="input__label-content input__label-content--hideo"></span>
								</label>
							</span>
                        <span class="input input--hideo">
								<input class="input__field input__field--hideo" type="password" id="login-password" placeholder="请输入密码" tabindex="2" maxlength="15"/>
								<label class="input__label input__label--hideo" for="login-password">
									<i class="fa fa-fw fa-lock icon icon--hideo"></i>
									<span class="input__label-content input__label-content--hideo"></span>
								</label>
							</span>
                    </section>
                </div>
                <div class="form-actions">
                    <a tabindex="4" class="btn pull-left btn-link text-muted" onClick="goto_forget()">忘记密码?</a>
                    <a tabindex="5" class="btn btn-link text-muted" onClick="goto_register()">注册</a>
                    <input class="btn btn-primary" type="button" tabindex="3" onClick="login()" value="登录"
                           style="color:white;"/>
                </div>
            </form>
        </div>
        <!-- 忘记密码页面 -->
        <div class="login sign-out-htm">
            <form action="#" method="post" class="container offset1 loginform">
                <!-- 猫头鹰控件 -->
                <div id="owl-login" class="forget-owl">
                    <div class="hand"></div>
                    <div class="hand hand-r"></div>
                    <div class="arms">
                        <div class="arm"></div>
                        <div class="arm arm-r"></div>
                    </div>
                </div>
                <div class="pad input-container">
                    <section class="content">
                        <span class="input input--hideo">
								<input class="input__field input__field--hideo" type="text" id="forget-username" autocomplete="off" placeholder="请输入用户名"/>
								<label class="input__label input__label--hideo" for="forget-username">
									<i class="fa fa-fw fa-user icon icon--hideo"></i>
									<span class="input__label-content input__label-content--hideo"></span>
								</label>
							</span>
                        <span class="input input--hideo">
								<input class="input__field input__field--hideo" type="email" id="forget-email" autocomplete="off" placeholder="输入注册邮箱，自动发送验证码"/>
								<label class="input__label input__label--hideo" for="forget-email">
									<i class="fa fa-fw fa-send icon icon--hideo"></i>
									<span class="input__label-content input__label-content--hideo"></span>
								</label>
							</span>
                        <span class="input input--hideo">
								<input class="input__field input__field--hideo" type="text" id="forget-code" autocomplete="off" placeholder="请输入注册码"/>
								<label class="input__label input__label--hideo" for="forget-code">
									<i class="fa fa-fw fa-code icon icon--hideo"></i>
									<span class="input__label-content input__label-content--hideo"></span>
								</label>
							</span>
                        <span class="input input--hideo">
								<input class="input__field input__field--hideo" type="password" id="forget-password" placeholder="请重置密码" />
								<label class="input__label input__label--hideo" for="forget-password">
									<i class="fa fa-fw fa-lock icon icon--hideo"></i>
									<span class="input__label-content input__label-content--hideo"></span>
								</label>
							</span>
                    </section>
                </div>
                <div class="form-actions">
                    <a class="btn pull-left btn-link text-muted" onClick="goto_login()">返回登录</a>
                    <input class="btn btn-primary" type="button" onClick="forget()" value="重置密码"
                           style="color:white;"/>
                </div>
            </form>
        </div>
        <!-- 注册页面 -->
        <div class="login sign-up-htm">
            <form action="#" method="post" class="container offset1 loginform">
                <!-- 猫头鹰控件 -->
                <div id="owl-login" class="register-owl">
                    <div class="hand"></div>
                    <div class="hand hand-r"></div>
                    <div class="arms">
                        <div class="arm"></div>
                        <div class="arm arm-r"></div>
                    </div>
                </div>
                <div class="pad input-container">
                    <section class="content">
                        <!--用户名-->
                        <span class="input input--hideo">
								<input class="input__field input__field--hideo" type="text" id="register-username"
                                       autocomplete="off" placeholder="请输入用户名" maxlength="15"/>
								<label class="input__label input__label--hideo" for="register-username">
									<i class="fa fa-fw fa-user icon icon--hideo"></i>
									<span class="input__label-content input__label-content--hideo"></span>
								</label>
							</span>
                        <!--笔名-->
                        <span class="input input--hideo">
								<input class="input__field input__field--hideo" type="text" id="register-account"
                                       autocomplete="off" placeholder="请输入笔名" maxlength="15"/>
								<label class="input__label input__label--hideo" for="register-account">
									<i class="fa fa-fw fa-pencil-square-o icon icon--hideo"></i>
									<span class="input__label-content input__label-content--hideo"></span>
								</label>
							</span>
                        <!--设置密码-->
                        <span class="input input--hideo">
								<input class="input__field input__field--hideo" type="password" id="register-password"
                                       placeholder="请输入密码" maxlength="15"/>
								<label class="input__label input__label--hideo" for="register-password">
									<i class="fa fa-fw fa-lock icon icon--hideo"></i>
									<span class="input__label-content input__label-content--hideo"></span>
								</label>
							</span>
                        <!--确认密码-->
                        <span class="input input--hideo">
								<input class="input__field input__field--hideo" type="password" id="register-repassword"
                                       placeholder="请确认密码" maxlength="15"/>
								<label class="input__label input__label--hideo" for="register-repassword">
									<i class="fa fa-fw fa-lock icon icon--hideo"></i>
									<span class="input__label-content input__label-content--hideo"></span>
								</label>
							</span>
                        <!--填写邮箱获取注册码-->
                        <span class="input input--hideo">
								<input class="input__field input__field--hideo" type="email" id="register-email"
                                       autocomplete="off" placeholder="请输入邮箱" maxlength="320"/>
								<label class="input__label input__label--hideo" for="register-email">
									<i class="fa fa-fw fa-send icon icon--hideo"></i>
									<span class="input__label-content input__label-content--hideo"></span>
								</label>
							</span>
                        <!--注册码-->
                        <span class="input input--hideo">
								<input class="input__field input__field--hideo" type="text" id="register-code"
                                       autocomplete="off" placeholder="请输入注册码"/>
								<label class="input__label input__label--hideo" for="register-code">
									<i class="fa fa-fw fa-code icon icon--hideo"></i>
									<span class="input__label-content input__label-content--hideo"></span>
								</label>
							</span>
                    </section>
                </div>
                <div class="form-actions">
                    <a class="btn pull-left btn-link text-muted" onClick="goto_login()">返回登录</a>
                    <input class="btn btn-primary" type="button" onClick="register()" value="注册"
                           style="color:white;"/>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
<script>
    $(function () {
        $("#register-email").change(function () {
            var email=$("#register-email").val();
            var title="也许有用 技术论坛 - MAYBE IT WORKS 欢迎注册验证码";
            //验证邮箱格式
            var flag = false;
            var regExp2 = new RegExp("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");
            if(!regExp2.test(email)){
                $.pt({
                    target: $("#register-email"),
                    position: 'r',
                    align: 't',
                    width: 'auto',
                    height: 'auto',
                    content:"邮箱格式不正确"
                });
                flag = true;
            }
            if (flag){
                return false;
            }else {
                spop({
                    template: '<h4 class="spop-title">注册码以发送至'+email+'</h4>弹窗即将于3秒后自动关闭',
                    position: 'top-center',
                    style: 'success',
                    autoclose: 3000,
                    onOpen : function(){
                        var second = 2;
                        var showPop = setInterval(function(){
                            if(second == 0){
                                clearInterval(showPop);
                            }
                            $('.spop-body').html('<h4 class="spop-title">注册码以发送至'+email+'</h4>弹窗即将于'+second+'秒后自动关闭');
                            second--;
                        },1000);
                    },
                    onClose : function(){
                        /* send()*/
                    }
                });
                $.ajax({
                    type:'post',
                    url:'/loginCenter/send',
                    data:{"email":$("#register-email").val(),"title":title},
                    dataType: "text",
                    async: true,
                    success:function (data) {
                        if (data==1){
                            return false
                        }else if (data==0){
                            $.pt({
                                target: $("#register-email"),
                                position: 'r',
                                align: 't',
                                width: 'auto',
                                height: 'auto',
                                content:"不要重复申请验证码"
                            });
                        }
                    },
                    error:function () {
                        alert("注册异常");
                    }
                });
            }
        })
        //找回获取code
        $("#forget-email").change(function () {
            var email=$("#forget-email").val();
            var title="也许有用 技术论坛 - MAYBE IT WORKS 账号重置验证码";
            //验证邮箱格式
            var flag = false;
            var regExp2 = new RegExp("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");
            if(!regExp2.test(email)){
                $.pt({
                    target: $("#forget-email"),
                    position: 'r',
                    align: 't',
                    width: 'auto',
                    height: 'auto',
                    content:"邮箱格式不正确"
                });
                flag = true;
            }
            if (flag){
                return false;
            }else {
                spop({
                    template: '<h4 class="spop-title">验证码以发送至'+email+'</h4>弹窗即将于3秒后自动关闭',
                    position: 'top-center',
                    style: 'success',
                    autoclose: 3000,
                    onOpen : function(){
                        var second = 2;
                        var showPop = setInterval(function(){
                            if(second == 0){
                                clearInterval(showPop);
                            }
                            $('.spop-body').html('<h4 class="spop-title">验证码以发送至'+email+'</h4>弹窗即将于'+second+'秒后自动关闭');
                            second--;
                        },1000);
                    },
                    onClose : function(){
                        /* send()*/
                    }
                });
                $.ajax({
                    type:'post',
                    url:'/loginCenter/send',
                    data:{"email":$("#forget-email").val(),"title":title},
                    dataType: "text",
                    async: true,
                    success:function (data) {
                        if (data==1){
                            return false
                        }else if (data==0){
                            $.pt({
                                target: $("#forget-email"),
                                position: 'r',
                                align: 't',
                                width: 'auto',
                                height: 'auto',
                                content:"不要重复申请验证码"
                            });
                        }
                    },
                    error:function () {
                        alert("重置密码异常");
                    }
                });
            }
        })
    });

</script>
</html>
